/*
 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/*
 * @(#)DBMetaClient2.java	1.16 02/01/12
 */

package jdbcts.dbMeta.dbMeta2;

import java.io.*;
import java.util.*;

import java.sql.*;
import javax.sql.*;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.sun.cts.util.*;
import com.sun.cts.porting.*;
import com.sun.cts.harness.*;

import java.rmi.RemoteException;

import javasoft.sqe.javatest.Status;
import jdbcts.SuperTest;
import jdbcts.common.DataSourceConnection;
import jdbcts.common.DriverManagerConnection;
import jdbcts.common.dbSchema;

import com.sun.cts.tests.jdbc.ee.common.*;

// Merant DataSource class
//import com.merant.sequelink.jdbcx.datasource.*;

/**
 * The DBMetaClient2 class tests methods of DatabaseMetaData interface using
 * Sun's J2EE Reference Implementation.
 * 
 * @author
 * @version 1.7, 06/16/99
 */

public class DBMetaClient2 extends SuperTest implements Serializable
{
    private static final String testName = "jdbc.ee.dbMeta.dbMeta2";

    // Naming specific member variables
    private CTSNamingContextInterface jc = null;

    // Harness requirements

    private transient static Connection conn = null;

    private transient static DatabaseMetaData dbmd = null;

    private DataSource ds1 = null;

    private static dbSchema dbSch = null;

    // private String dbName=null,dbUser=null,drManager=null;
    private static String drManager = null;

    // private String
    // sCatalogName=null,sSchemaName=null,sPtable=null,sFtable=null;

    /* Run test in standalone mode */
    // public static void main(String[] args)
    // {
    // DBMetaClient2 theTests = new DBMetaClient2();
    // Status s=theTests.run(args, System.out, System.err);
    // s.exit();
    // }
    /* Test setup: */
    /*
     * @class.setup_props: Driver, the Driver name; db1, the database name with
     * url; user1, the database user name; password1, the database password;
     * db2, the database name with url; user2, the database user name;
     * password2, the database password; DriverManager, flag for DriverManager;
     * ptable, the primary table; ftable, the foreign table; cofSize, the
     * initial size of the ptable; cofTypeSize, the initial size of the ftable;
     * binarySize, size of binary data type; varbinarySize, size of varbinary
     * data type; longvarbinarySize, size of longvarbinary data type;
     * 
     * @class.testArgs: -ap ctssql.stmt
     */
    @BeforeClass
    // public static void setup(String[] args, Properties p) throws Exception
    public static void setup() throws Exception
    {
	try
	{
	    try
	    {
		// drManager = p.getProperty("DriverManager","");
		drManager = isDRManager;
		// dbName = p.getProperty("db1","");
		// dbUser = p.getProperty("user1","");
		// sPtable = p.getProperty("ptable","CTSTABLE1");
		// sFtable = p.getProperty("ftable","CTSTABLE2");
		// if (dbName.length() == 0)
		// throw new Exception("Invalid db1  Database Name");
		// if (dbUser.length() == 0)
		// throw new Exception("Invalid Login Id");
		// if (sPtable.length() == 0)
		// throw new Exception("Invalid Primary table");
		// if (sFtable.length() == 0)
		// throw new Exception("Invalid Foreign table");
		if (drManager.length() == 0)
		    throw new Exception("Invalid DriverManager Name");

		// int nLocdbname = dbName.indexOf('=');
		// sCatalogName = dbName.substring(nLocdbname +1);
		// sCatalogName = sCatalogName.trim();
		// sSchemaName = dbUser;

		if (drManager.equals("yes"))
		{
		    logMsg("Using DriverManager");
		    DriverManagerConnection dmCon = new DriverManagerConnection();
		    // conn = dmCon.getConnection(p);
		    conn = dmCon.getConnection(null);
		}
		else
		{
		    logMsg("Using DataSource");
		    DataSourceConnection dsCon = new DataSourceConnection();
		    // conn = dsCon.getConnection(p);
		    conn = dsCon.getConnection(null);
		}
		dbSch = new dbSchema();
		// dbSch.createData(p,conn);
		dbmd = conn.getMetaData();
	    }
	    catch (SQLException ex)
	    {
		logErr("SQL Exception : " + ex.getMessage());
	    }
	}
	catch (Exception e)
	{
	    logErr("Setup Failed!");
	    TestUtil.printStackTrace(e);
	}
    }

    /*
     * @testName: testStoresMixedCaseIdentifiers
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * storesMixedCaseIdentifiers() method must return a boolean value; true if
     * DBMS allows mixed case SQL Identifiers in SQL statements as
     * case-insensitive and stores them as all mixed cases in its metadata
     * tables and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the storesMixedCaseIdentifiers() method It should
     * return a boolean value
     */
    @Test
    public void testStoresMixedCaseIdentifiers() throws Exception
    {
	try
	{
	    // invoke on the storesMixedCaseIdentifiers
	    logMsg("Calling storesMixedCaseIdentifiers on DatabaseMetaData");
	    boolean retValue = dbmd.storesMixedCaseIdentifiers();
	    if (retValue)
	    {
		logMsg("storesMixedCaseIdentifiers method returns unquoted SQL identifiers stored as mixed case");
	    }
	    else
	    {
		logMsg("storesMixedCaseIdentifiers method returns unquoted SQL identifiers not stored as mixed case");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to storesMixedCaseIdentifiers is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to storesMixedCaseIdentifiers is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsMixedCaseQuotedIdentifiers
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsMixedCaseQuotedIdentifiers() method must return a boolean value;
     * true if DBMS allows mixed case quoted SQL Identifiers in SQL statements
     * as case-insensitive and stores them as all mixed cases in its metadata
     * tables and false otherwise. A JDBC Compliant driver will always return
     * true. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsMixedCaseQuotedIdentifiers() method It
     * should return a boolean value
     */
    @Test
    public void testSupportsMixedCaseQuotedIdentifiers() throws Exception
    {
	try
	{
	    // invoke on the supportsMixedCaseQuotedIdentifiers
	    logMsg("Calling supportsMixedCaseQuotedIdentifiers on DatabaseMetaData");
	    boolean retValue = dbmd.supportsMixedCaseQuotedIdentifiers();
	    if (retValue)
	    {
		logMsg("supportsMixedCaseQuotedIdentifiers method is supported");
	    }
	    else
	    {
		logMsg("supportsMixedCaseQuotedIdentifiers method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsMixedCaseQuotedIdentifiers is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsMixedCaseQuotedIdentifiers is Failed!", e);
	}
    }

    /*
     * @testName: testStoresUpperCaseQuotedIdentifiers
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * storesUpperCaseQuotedIdentifiers() method must return a boolean value;
     * true if DBMS allows mixed case quoted SQL Identifiers in SQL statements
     * as case-insensitive and stores them as all upper cases in its metadata
     * tables and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the storesUpperCaseQuotedIdentifiers() method It
     * should return a boolean value
     */
    @Test
    public void testStoresUpperCaseQuotedIdentifiers() throws Exception
    {
	try
	{
	    // invoke on the storesUpperCaseQuotedIdentifiers
	    logMsg("Calling storesUpperCaseQuotedIdentifiers on DatabaseMetaData");
	    boolean retValue = dbmd.storesUpperCaseQuotedIdentifiers();
	    if (retValue)
	    {
		logMsg("storesUpperCaseQuotedIdentifiers method returns SQL identifiers stored as upper case");
	    }
	    else
	    {
		logMsg("storesUpperCaseQuotedIdentifiers method returns SQL identifiers not stored as upper case");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to storesUpperCaseQuotedIdentifiers is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to storesUpperCaseQuotedIdentifiers is Failed!", e);
	}
    }

    /*
     * @testName: testStoresLowerCaseQuotedIdentifiers
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * storesLowerCaseQuotedIdentifiers() method must return a boolean value;
     * true if DBMS allows mixed case quoted SQL Identifiers in SQLstatements as
     * case-insensitive and stores them as all lower cases in its metadata
     * tables and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the storesLowerCaseQuotedIdentifiers() method It
     * should return a boolean value
     */
    @Test
    public void testStoresLowerCaseQuotedIdentifiers() throws Exception
    {
	try
	{
	    // invoke on the storesLowerCaseQuotedIdentifiers
	    logMsg("Calling storesLowerCaseQuotedIdentifiers on DatabaseMetaData");
	    boolean retValue = dbmd.storesLowerCaseQuotedIdentifiers();
	    if (retValue)
	    {
		logMsg("storesLowerCaseQuotedIdentifiers method returns SQL identifiers stored as lower case");
	    }
	    else
	    {
		logMsg("storesLowerCaseQuotedIdentifiers method returns SQL identifiers not stored as lower case");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to storesLowerCaseQuotedIdentifiers is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to storesLowerCaseQuotedIdentifiers is Failed!", e);
	}
    }

    /*
     * @testName: testStoresMixedCaseQuotedIdentifiers
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * storesMixedCaseQuotedIdentifiers() method must return a boolean value;
     * true if DBMS allows mixed case quoted SQL Identifiers in SQL statements
     * as case-insensitive and stores them as all mixed cases in its metadata
     * tables and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the storesMixedCaseQuotedIdentifiers() method It
     * should return a boolean value
     */
    @Test
    public void testStoresMixedCaseQuotedIdentifiers() throws Exception
    {
	try
	{
	    // invoke on the storesMixedCaseQuotedIdentifiers
	    logMsg("Calling storesMixedCaseQuotedIdentifiers on DatabaseMetaData");
	    boolean retValue = dbmd.storesMixedCaseQuotedIdentifiers();
	    if (retValue)
	    {
		logMsg("storesMixedCaseQuotedIdentifiers method returns SQL identifiers stored as mixed case");
	    }
	    else
	    {
		logMsg("storesMixedCaseQuotedIdentifiers method returns SQL identifiers not stored as mixed case");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to storesMixedCaseQuotedIdentifiers is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to storesMixedCaseQuotedIdentifiers is Failed!", e);
	}
    }

    /*
     * @testName: testGetIdentifierQuoteString
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * getIdentifierQuoteString() method must return a String object
     * representing the quoting string or a space if the database does not
     * support quoting identifiers. A JDBC Compliant driver always uses a double
     * quote character ("). (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the getIdentifierQuoteString() method It should
     * return a String
     */
    @Test
    public void testGetIdentifierQuoteString() throws Exception
    {
	try
	{
	    // invoke on the getIdentifierQuoteString
	    logMsg("Calling getIdentifierQuoteString on DatabaseMetaData");
	    String sRetValue = dbmd.getIdentifierQuoteString();

	    if (sRetValue.equals(""))
	    {
		logMsg("The database does not support quoting identifiers");
	    }
	    else
		if (sRetValue instanceof String)
		{
		    logMsg("getIdentifierQuoteString method returns "
			    + sRetValue);
		}
		else
		    if (sRetValue == null)
		    {
			logErr("getIdentifierQuoteString returns an Invalid value");
			throw new Exception(
				"Call to getIdentfierQuoteString is Failed!");
		    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to getIdentifierQuoteString is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to getIdentifierQuoteString is Failed!",
		    e);
	}
    }

    /*
     * @testName: testGetSQLKeywords
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getSQLKeywords() method
     * must return a String object that is comma separated list of keywords used
     * by the database that are not also SQL-92 keywords.(See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the getSQLKeywords() method It should return a
     * String
     */
    @Test
    public void testGetSQLKeywords() throws Exception
    {
	try
	{
	    // invoke on the getSQLKeywords
	    logMsg("Calling getSQLKeywords on DatabaseMetaData");
	    String sRetValue = dbmd.getSQLKeywords();

	    if (sRetValue == null)
	    {
		logMsg("getSQLKeywords method does not returns the list of SQLKeywords ");
	    }
	    else
	    {
		logMsg("getSQLKeywords method returns: " + sRetValue);
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to getSQLKeywords is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to getSQLKeywords is Failed!", e);
	}
    }

    /*
     * @testName: testGetNumericFunctions
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getNumericFunctions()
     * method must return a String object that is a comma separated list of math
     * functions; These are the X/Open CLI math function names used in the JDBC
     * function escape clause. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the getNumericFunctions() method It should return a
     * String
     */
    @Test
    public void testGetNumericFunctions() throws Exception
    {
	try
	{
	    // invoke on the getNumericFunctions
	    logMsg("Calling getNumericFunctions on DatabaseMetaData");
	    String sRetValue = dbmd.getNumericFunctions();
	    if (sRetValue == null)
	    {
		logMsg("getNumericFunctions method does not returns the comma-separated list of math functions ");
	    }
	    else
	    {
		logMsg("getNumericFunctions method returns: " + sRetValue);
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to getNumericFunctions is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to getNumericFunctions is Failed!", e);
	}
    }

    /*
     * @testName: testGetStringFunctions
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getStringFunctions()
     * method must return a String object that is a comma separated list of
     * string functions; These are the X/Open CLI string function names used in
     * the JDBC function escape clause. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the getStringFunctions() method It should return a
     * String
     */
    @Test
    public void testGetStringFunctions() throws Exception
    {
	try
	{
	    // invoke on the getStringFunctions
	    logMsg("Calling getStringFunctions on DatabaseMetaData");
	    String sRetValue = dbmd.getStringFunctions();
	    if (sRetValue == null)
	    {
		logMsg("getStringFunctions method does not returns the comma-separated list of string functions ");
	    }
	    else
	    {
		logMsg("getStringFunctions method returns: " + sRetValue);
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to getStringFunctions is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to getStringFunctions is Failed!", e);
	}
    }

    /*
     * @testName: testGetSystemFunctions
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getSystemFunctions()
     * method must return a String object that is a comma separated list of
     * string functions; These are the X/Open CLI system function names used in
     * the JDBC function escape clause. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the getSystemFunctions() method It should return a
     * String
     */
    @Test
    public void testGetSystemFunctions() throws Exception
    {
	try
	{
	    // invoke on the getSystemFunctions
	    logMsg("Calling getSystemFunctions on DatabaseMetaData");
	    String sRetValue = dbmd.getSystemFunctions();
	    if (sRetValue == null)
	    {
		logMsg("getSystemFunctions methd does not returns the comma-separated list of system functions ");
	    }
	    else
	    {
		logMsg("getSystemFunctions method returns: " + sRetValue);
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to getSystemFunctions is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to getSystemFunctions is Failed!", e);
	}
    }

    /*
     * @testName: testGetTimeDateFunctions
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getSystemFunctions
     * method must return a String object that is a comma separated list of time
     * and date functions; These are the X/Open CLI time and date function names
     * used in the JDBC function escape clause. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the getTimeDateFunctions() method It should return
     * a String
     */
    @Test
    public void testGetTimeDateFunctions() throws Exception
    {
	try
	{
	    // invoke on the getTimeDateFunctions
	    logMsg("Calling getTimeDateFunctions on DatabaseMetaData");
	    String sRetValue = dbmd.getTimeDateFunctions();
	    if (sRetValue == null)
	    {
		logMsg("getTimeDateFunctions method does not returns the comma-separated list of time and date functions ");
	    }
	    else
	    {
		logMsg("getTimeDateFunctions method returns: " + sRetValue);
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to getTimeDateFunctions is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to getTimeDateFunctions is Failed!", e);
	}
    }

    /*
     * @testName: testGetSearchStringEscape
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getSystemFunctions()
     * method must return a String object used to escape wildcard characters;
     * (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the getSearchStringEscape() method It should return
     * a String
     */
    @Test
    public void testGetSearchStringEscape() throws Exception
    {
	try
	{
	    // invoke on the getSearchStringEscape
	    logMsg("Calling getSearchStringEscape on DatabaseMetaData");
	    String sRetValue = dbmd.getSearchStringEscape();
	    if (sRetValue == null)
	    {
		logMsg("getSearchStringEscape  method does not returns the string used to escape wildcard characters ");
	    }
	    else
	    {
		logMsg("getSearchStringEscape method returns: " + sRetValue);
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to getSearchStringEscape is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to getSearchStringEscape is Failed!", e);
	}
    }

    /*
     * @testName: testGetExtraNameCharacters
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * getExtraNameCharacters() method must return a String object containing
     * the extra characters; (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the getExtraNameCharacters() method It should
     * return a String
     */
    @Test
    public void testGetExtraNameCharacters() throws Exception
    {
	try
	{
	    // invoke on the getExtraNameCharacters
	    logMsg("Calling getExtraNameCharacters on DatabaseMetaData");
	    String sRetValue = dbmd.getExtraNameCharacters();
	    if (sRetValue == null)
	    {
		logMsg("getExtraNameCharacters method does not returns the string containing the extra characters ");
	    }
	    else
	    {
		logMsg("getExtraNameCharacters method returns: " + sRetValue);
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to getExtraNameCharacters is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to getExtraNameCharacters is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsAlterTableWithAddColumn
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsAlterTableWithAddColumn() method must return a boolean value;
     * true if the database supports ALTER TABLE with add Column and false
     * otherwise (See JDK 1.2.2 API documentation).
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsAlterTableWithAddColumn() method It
     * should return a boolean value
     */
    @Test
    public void testSupportsAlterTableWithAddColumn() throws Exception
    {
	try
	{
	    // invoke on the supportsAlterTableWithAddColumn
	    logMsg("Calling supportsAlterTableWithAddColumn on DatabaseMetaData");
	    boolean retValue = dbmd.supportsAlterTableWithAddColumn();
	    if (retValue)
	    {
		logMsg("supportsAlterTableWithAddColumn is supported");
	    }
	    else
	    {
		logMsg("supportsAlterTableWithAddColumn is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsAlterTableWithAddColumn is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsAlterTableWithAddColumn is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsAlterTableWithDropColumn
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsAlterTableWithDropColumn() method must return a boolean value;
     * true if the database supports ALTER TABLE with drop column and false
     * otherwise (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsAlterTableWithDropColumn() method It
     * should return a boolean value
     */
    @Test
    public void testSupportsAlterTableWithDropColumn() throws Exception
    {
	try
	{
	    // invoke on the supportsAlterTableWithDropColumn
	    logMsg("Calling supportsAlterTableWithDropColumn on DatabaseMetaData");
	    boolean retValue = dbmd.supportsAlterTableWithDropColumn();
	    if (retValue)
	    {
		logMsg("supportsAlterTableWithDropColumn is supported");
	    }
	    else
	    {
		logMsg("supportsAlterTableWithDropColumn is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsAlterTableWithDropColumn is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsAlterTableWithDropColumn is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsColumnAliasing
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsColumnAliasing() method must return a boolean value; true if the
     * database supports column aliasing and false otherwise. A JDBC compliant
     * driver must always return true. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsColumnAliasing() method It should
     * return a true value
     */
    @Test
    public void testSupportsColumnAliasing() throws Exception
    {
	try
	{
	    // invoke on the supportsColumnAliasing
	    logMsg("Calling supportsColumnAliasing on DatabaseMetaData");
	    boolean retValue = dbmd.supportsColumnAliasing();
	    logTrace("A JDBC CompliantTM driver always returns true");
	    if (retValue)
	    {
		logMsg("supportsColumnAliasing is supported");
	    }
	    else
	    {
		logMsg("supportsColumnAliasing is not supported");
		throw new Exception(
			"supportsColumnAliasing should always return true!");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsColumnAliasing is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsColumnAliasing is Failed!", e);
	}
    }

    /*
     * @testName: testNullPlusNonNullIsNull
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The nullPlusNonNullIsNull()
     * method must return a boolean value; true if the concatenation of a NULL
     * value and a non-NULL value results in a NULL value and false otherwise. A
     * JDBC compliant driver must always return true. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the nullPlusNonNullIsNull() method It should return
     * a boolean value
     */
    @Test
    public void testNullPlusNonNullIsNull() throws Exception
    {
	try
	{
	    // invoke on the nullPlusNonNullIsNull
	    logMsg("Calling nullPlusNonNullIsNull on DatabaseMetaData");
	    boolean retValue = dbmd.nullPlusNonNullIsNull();
	    logTrace("A JDBC CompliantTM driver always returns true");
	    if (retValue)
	    {
		logMsg("nullPlusNonNullIsNull method returns a NULL value for the concatenations between NULL and non-NULL");
	    }
	    else
	    {
		logMsg("nullPlusNonNullIsNull method does not returns a NULL value for the concatenations between NULL and non-NULL");
		throw new Exception(
			"nullPlusNonNullIsNull method should always return true!");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to nullPlusNonNullIsNull is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to nullPlusNonNullIsNull is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsConvert
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The supportsConvert()
     * method must return a boolean value; true if the database supports the
     * scalar function CONVERT for for the conversion of one JDBC type to
     * another and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsConvert() method It should return a
     * boolean value
     */
    @Test
    public void testSupportsConvert() throws Exception
    {
	try
	{
	    // invoke on the supportsConvert
	    logMsg("Calling supportsConvert on DatabaseMetaData");
	    boolean retValue = dbmd.supportsConvert();
	    if (retValue)
	    {
		logMsg("supportsConvert method is supported");
	    }
	    else
	    {
		logMsg("supportsConvert method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsConvert is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsConvert is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsConvert01
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The supportsConvert(int
     * fromType, int toType) method must return a boolean value; true if the
     * database supports the scalar function CONVERT for conversions between the
     * JDBC types fromType and toType and false otherwise. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsConvert(ARRAY, VARCHAR) method It
     * should return a boolean value
     */
    @Test
    public void testSupportsConvert01() throws Exception
    {
	try
	{
	    // invoke on the supportsConvert
	    logMsg("Calling supportsConvert(ARRAY, VARCHAR) on DatabaseMetaData");
	    boolean retValue = dbmd.supportsConvert(Types.ARRAY, Types.VARCHAR);
	    if (retValue)
	    {
		logMsg("supportsConvert(ARRAY, VARCHAR) method is supported");
	    }
	    else
	    {
		logMsg("supportsConvert(ARRAY, VARCHAR) method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsConvert is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsConvert is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsConvert02
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The supportsConvert(int
     * fromType, int toType) method must return a boolean value; true if the
     * database supports the scalar function CONVERT for conversions between the
     * JDBC types fromType and toType and false otherwise. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsConvert(BIGINT, VARCHAR) method It
     * should return a boolean value
     */
    @Test
    public void testSupportsConvert02() throws Exception
    {
	try
	{
	    // invoke on the supportsConvert
	    logMsg("Calling supportsConvert(BIGINT, VARCHAR) on DatabaseMetaData");
	    boolean retValue = dbmd
		    .supportsConvert(Types.BIGINT, Types.VARCHAR);
	    if (retValue)
	    {
		logMsg("supportsConvert(BIGINT, VARCHAR) method is supported");
	    }
	    else
	    {
		logMsg("supportsConvert(BIGINT, VARCHAR) method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsConvert is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsConvert is Failed!", e);
	}
    }

    /* cleanup */
    @AfterClass
    public static void cleanup() throws Exception
    {
	try
	{
	    // Close the database
	    // dbSch.destroyData(conn);
	    dbSch.dbUnConnect(conn);
	    logMsg("Cleanup ok;");
	}
	catch (Exception e)
	{
	    logErr("An error occurred while closing the database connection");
	}
    }
}
